package br.com.werp.suporte.Relatorios;

import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import com.egen.util.jdbc.*;
import com.egen.util.text.*;

/**
 * Creation Date 18/12/2006 09:57:36
 * Last Modify Date 18/12/2006 14:33:20
 */

public class RelatorioManutencaoAction extends com.egen.util.struts.AbstractAction {

  public ActionForward perform_gerar_action(ActionMapping mapping,
      ActionForm form, HttpServletRequest request,
      HttpServletResponse response) {
    HttpSession session = request.getSession(true);
    ActionForward actionForward = null;
    try {
      // ----------------------------------------------------------------------
      br.com.werp.regras.geral.Suporte suporte =
        br.com.werp.regras.geral.FabricaSubSistema.getSuporte();
      String usuario = (String) session.getAttribute("j_username");
      String empresa = (String) session.getAttribute("filialId");
      request.setAttribute("Relatorio",
          suporte.gerarRelatorioManutencao(form, usuario, empresa));

      actionForward = mapping.findForward("RelatorioVisao");
      //-------------------------------------------------------------------------
    } catch (Exception e) {
      ActionErrors errors = new ActionErrors();
      errors.add("ActionErrors.GLOBAL_ERROR",
          new ActionError("error.action.exception",
              (e)));
      request.setAttribute(org.apache.struts.Globals.ERROR_KEY, errors);
      session.setAttribute("exception",
          (e));
      actionForward = mapping.findForward("same");
    }
    return actionForward;
  }

  public ActionForward perform_resetfull_action(ActionMapping mapping,
      ActionForm form, HttpServletRequest request,
      HttpServletResponse response) {
    HttpSession session = request.getSession(true);
    ActionForward actionForward = null;
    try {
      //-------------------------------------------------
      form.reset(null, null);
      //-------------------------------------------------
      actionForward = mapping.findForward("same");
    } catch (Exception e) {
      ActionErrors errors = new ActionErrors();
      errors.add("ActionErrors.GLOBAL_ERROR",
          new ActionError("error.action.exception",
              (e)));
      request.setAttribute(org.apache.struts.Globals.ERROR_KEY, errors);
      session.setAttribute("exception",
          (e));
      actionForward = mapping.findForward("same");
    }
    return actionForward;
  }

}
